cmake_minimum_required(VERSION 3.4)

project(mpilab CXX)

list(PREPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/../cmake)

set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

## 依赖
if(NOT FRANKA_IS_FOUND)
    find_package(Franka REQUIRED)
endif()
find_package(Eigen3 REQUIRED)
find_package(Poco REQUIRED COMPONENTS Foundation)

set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

## 添加库
add_library(mpi_motion STATIC
    src/mpi_motion.cpp
)
target_link_libraries(mpi_motion PUBLIC Franka::Franka Eigen3::Eigen3)
target_include_directories(mpi_motion PUBLIC ${CMAKE_CURRENT_LIST_DIR}/include)

## 添加可执行文件
set(EXAMPLES
    mpi_test
    test_joint_motion
)

foreach(example ${EXAMPLES})
  add_executable(${example} ${example}.cpp)
  target_link_libraries(${example} Franka::Franka Eigen3::Eigen3 mpi_motion)
endforeach()

# target_link_libraries(exp Threads::Threads)
# target_link_libraries(exp Poco::Foundation)

## 安装
install(TARGETS ${EXAMPLES}
#   ARCHIVE DESTINATION mpilab/lib
#   LIBRARY DESTINATION mpilab/lib
  RUNTIME DESTINATION bin/mpi_motion
)
